package com.moleq.device.printer;

public abstract class Printer implements IPrinter {

	public static final String EPSON_WIRELESS_PRINTER = "epson.wireless.printer";
	public static final String CASIO_VX100_PRINTER = "casio.vx100.printer";

	public final static int FONT_SINGLE_SIZE = 0;
	public final static int FONT_DOUBLE_SIZE = 1;
	public final static int FONT_DOUBLE_HEIGHT = 2;

	public final static int LEFT = 10;
	public final static int CENTER = 20;
	public final static int RIGHT = 30;
	
	public static final int FULL_LINE = 100;
	public static final int CUSTOM_LINE = 200;
	
	public boolean mEnable = false;
	public boolean mIsBusy = false;
	public boolean mIsAvailable = false;
	public boolean mOutOfPaper = false;

	public String ResponseMsg = "";

	public int lineWidth = -1;
	public PrinterBufferRowColection rows = new PrinterBufferRowColection();

	public PrinterBufferRow newRow() {
		PrinterBufferRow newBuffer = new PrinterBufferRow();
//		newBuffer.setWidth(lineWidth);
		return newBuffer;
	}
	
	public void setPrinterBuffer(PrinterBufferRowColection buffer){
		rows = buffer;
	}
	
	public boolean ismOutOfPaper() {
		return mOutOfPaper;
	}

	public void setmOutOfPaper(boolean mOutOfPaper) {
		this.mOutOfPaper = mOutOfPaper;
	}

	@Override
	public void setEnable(boolean b) {
		mEnable = b;
	}

	@Override
	public boolean isEnable() {
		return mEnable;

	}

	@Override
	public boolean isBusy() {
		return mIsBusy;

	}
	
	@Override
	public String getResponseMsg() {
		return this.ResponseMsg;
	}
	
	@Override
	public void print() {
		
		if (rows != null) {
			for (int i = 0; i < rows.count(); i++) {
				print(rows.get(i).getContent(this.lineWidth));
			}
		}
	}

	
	@Override
	public void clearBuffer() {
		
		rows.clear();
	}
	
	@Override
	public void reset() {
		clearBuffer();
		ResponseMsg = "";
		
	}
	
	@Override
	public boolean isAvailable() {
		return mIsAvailable;
		
	}

}
